﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;

    public class DOM
    {


        public string Html;
        public XmlDocument DocumentModel;

        public DOM(string url)
        {
            Load(url);
        }

        public void Load(string url)
        {
            try
            {
                Html = Utilities.ScrapeHtml(url);
                DocumentModel = new XmlDocument();
                DocumentModel.LoadXml(Html);
            }
            catch (Exception ex)
            {
                
            }
        }

        public XmlNodeList Query(string query)
        {
            query = "//" + query;
            var matches = DocumentModel.SelectNodes(query);
            return matches;
        }

        public List<XmlNode> GetTableByHeader(string header)
        {
            return Utilities.GetTablesByHeader(DocumentModel, header);
        }

    }
